//
//  EditCardSheet.m
//  AnimatedFlashcards
//
//  Created by Timothy Costa on 11/2/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "EditCardController.h"


@implementation EditCardController
@synthesize side1;
@synthesize side2;
@synthesize hint;

-(void)awakeFromNib
{
}
-(IBAction)ok:(id)sender
{
	card.side1 = [side1 stringValue];
	card.side2 = [side2 stringValue];
	card.hint = [hint stringValue];
	[NSApp stopModal];
}
-(IBAction)cancel:(id)sender
{
	[NSApp stopModal];
}
-(void)openEditCardController:(Card*)cardToEdit
{
	card = cardToEdit;
	card.side1 ? [side1 setStringValue:cardToEdit.side1] : [side1 setStringValue:@""];
	card.side2 ? [side2 setStringValue:cardToEdit.side2] : [side2 setStringValue:@""];
	card.hint ? [hint setStringValue:cardToEdit.hint] : [hint setStringValue:@""];
	
	[NSApp beginSheet:editCardWindow 
	   modalForWindow:mainWindow 
		modalDelegate:nil
	   didEndSelector:nil
		  contextInfo:nil];
	
    [NSApp runModalForWindow:editCardWindow];
	
	[NSApp endSheet:editCardWindow];
	[editCardWindow orderOut:self];
}
@end
